package de.dqi.pong.graphics;

import java.awt.*;
import java.awt.Point;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

/**
 * TODO Display - finish class definition
 * <hr>
 * This is a gui element, more precisely a Canvas, that is used by Render.
 * It should be integrated into an applications GUI to allow for rendered images to be shown.
 * <hr><dl><dt>
 * Summary: </dt><br><dd>
 *  
 * </dd><br><dt>
 * Author: </dt><br><dd>
 *  Vincent
 * </dd></dl>
 */
public class Display
		extends JPanel {
	
	private BufferedImage	image;
	private Render			source;
	
	Display(Render source) {
		Toolkit toolkit = Toolkit.getDefaultToolkit();
		java.awt.Point hotSpot = new Point(0, 0);
		BufferedImage cursorImage = new BufferedImage(1, 1, BufferedImage.TRANSLUCENT);
		Cursor invisibleCursor = toolkit.createCustomCursor(cursorImage, hotSpot, "InvisibleCursor");
		setCursor(invisibleCursor);
		
		this.source = source;
		
		image = new BufferedImage(850, 700, BufferedImage.TYPE_INT_RGB);
		
	}
	
	@Override
	public void paint(Graphics g) {
		g.drawImage(image, 0, 0, null);
	}
	
	void drawFrame(int[] frame) {
		image.setRGB(0, 0, 850, 700, frame, 0, 850);
		
		repaint();
	}
	
	
}
